package com.sagframe.sagacity.sqltoy.plus.multi.interfaces;

import com.sagframe.sagacity.sqltoy.plus.conditions.interfaces.SFunction;

import java.util.Collection;
import java.util.Map;

public interface LambdaCompare<Children> {

    /**
     * ignore
     *
     * @param column
     * @param val
     */
    default <T> Children eq(SFunction<T, ?> column, Object val) {
        return eq(true, column, val);
    }

    /**
     * 等于 =
     *
     * @param condition 执行条件
     * @param column    字段
     * @param val       值
     * @return children
     */
    <T> Children eq(boolean condition, SFunction<T, ?> column, Object val);

    /**
     * ignore
     *
     * @param column
     * @param val
     */
    default <T> Children ne(SFunction<T, ?> column, Object val) {
        return ne(true, column, val);
    }

    /**
     * 不等于 &lt;&gt;
     *
     * @param condition 执行条件
     * @param column    字段
     * @param val       值
     * @return children
     */
    <T> Children ne(boolean condition, SFunction<T, ?> column, Object val);

    /**
     * ignore
     *
     * @param column
     * @param val
     */
    default <T> Children gt(SFunction<T, ?> column, Object val) {
        return gt(true, column, val);
    }

    /**
     * 大于 &gt;
     *
     * @param condition 执行条件
     * @param column    字段
     * @param val       值
     * @return children
     */
    <T> Children gt(boolean condition, SFunction<T, ?> column, Object val);

    /**
     * ignore
     *
     * @param column
     * @param val
     */
    default <T> Children ge(SFunction<T, ?> column, Object val) {
        return ge(true, column, val);
    }

    /**
     * 大于等于 &gt;=
     *
     * @param condition 执行条件
     * @param column    字段
     * @param val       值
     * @return children
     */
    <T> Children ge(boolean condition, SFunction<T, ?> column, Object val);

    /**
     * ignore
     *
     * @param column
     * @param val
     */
    default <T> Children lt(SFunction<T, ?> column, Object val) {
        return lt(true, column, val);
    }

    /**
     * 小于 &lt;
     *
     * @param condition 执行条件
     * @param column    字段
     * @param val       值
     * @return children
     */
    <T> Children lt(boolean condition, SFunction<T, ?> column, Object val);

    /**
     * ignore
     *
     * @param column
     * @param val
     */
    default <T> Children le(SFunction<T, ?> column, Object val) {
        return le(true, column, val);
    }

    /**
     * 小于等于 &lt;=
     *
     * @param condition 执行条件
     * @param column    字段
     * @param val       值
     * @return children
     */
    <T> Children le(boolean condition, SFunction<T, ?> column, Object val);

    /**
     * ignore
     *
     * @param column
     * @param val1
     * @param val2
     */
    default <T> Children between(SFunction<T, ?> column, Object val1, Object val2) {
        return between(true, column, val1, val2);
    }

    /**
     * BETWEEN 值1 AND 值2
     *
     * @param condition 执行条件
     * @param column    字段
     * @param val1      值1
     * @param val2      值2
     * @return children
     */
    <T> Children between(boolean condition, SFunction<T, ?> column, Object val1, Object val2);

    /**
     * ignore
     *
     * @param column
     * @param val1
     * @param val2
     */
    default <T> Children notBetween(SFunction<T, ?> column, Object val1, Object val2) {
        return notBetween(true, column, val1, val2);
    }

    /**
     * NOT BETWEEN 值1 AND 值2
     *
     * @param condition 执行条件
     * @param column    字段
     * @param val1      值1
     * @param val2      值2
     * @return children
     */
    <T> Children notBetween(boolean condition, SFunction<T, ?> column, Object val1, Object val2);

    /**
     * ignore
     *
     * @param column
     * @param val
     */
    default <T> Children like(SFunction<T, ?> column, Object val) {
        return like(true, column, val);
    }

    /**
     * LIKE '%值%'
     *
     * @param condition 执行条件
     * @param column    字段
     * @param val       值
     * @return children
     */
    <T> Children like(boolean condition, SFunction<T, ?> column, Object val);

    /**
     * ignore
     *
     * @param column
     * @param val
     */
    default <T> Children notLike(SFunction<T, ?> column, Object val) {
        return notLike(true, column, val);
    }

    /**
     * NOT LIKE '%值%'
     *
     * @param condition 执行条件
     * @param column    字段
     * @param val       值
     * @return children
     */
    <T> Children notLike(boolean condition, SFunction<T, ?> column, Object val);

    /**
     * ignore
     *
     * @param column
     * @param val
     */
    default <T> Children likeLeft(SFunction<T, ?> column, Object val) {
        return likeLeft(true, column, val);
    }

    /**
     * LIKE '%值'
     *
     * @param condition 执行条件
     * @param column    字段
     * @param val       值
     * @return children
     */
    <T> Children likeLeft(boolean condition, SFunction<T, ?> column, Object val);

    /**
     * ignore
     *
     * @param column
     * @param val
     */
    default <T> Children likeRight(SFunction<T, ?> column, Object val) {
        return likeRight(true, column, val);
    }

    /**
     * LIKE '值%'
     *
     * @param condition 执行条件
     * @param column    字段
     * @param val       值
     * @return children
     */
    <T> Children likeRight(boolean condition, SFunction<T, ?> column, Object val);

    /**
     * ignore
     *
     * @param column
     */
    
    default <T> Children isNull(SFunction<T, ?> column) {
        return isNull(true, column);
    }

    /**
     * 字段 IS NULL
     * <p>例: isNull("name")</p>
     *
     * @param condition 执行条件
     * @param column    字段
     * @return children
     */
    <T> Children isNull(boolean condition, SFunction<T, ?> column);

    /**
     * ignore
     *
     * @param column
     */
    default <T> Children isNotNull(SFunction<T, ?> column) {
        return isNotNull(true, column);
    }

    /**
     * 字段 IS NOT NULL
     * <p>例: isNotNull("name")</p>
     *
     * @param condition 执行条件
     * @param column    字段
     * @return children
     */
    <T> Children isNotNull(boolean condition, SFunction<T, ?> column);

    /**
     * ignore
     *
     * @param column
     * @param coll
     */
    default <T> Children in(SFunction<T, ?> column, Collection<?> coll) {
        return in(true, column, coll);
    }

    /**
     * 字段 IN (value.get(0), value.get(1), ...)
     * <p>例: in("id", Arrays.asList(1, 2, 3, 4, 5))</p>
     *
     * <li> 注意！集合为空若存在逻辑错误，请在 condition 条件中判断 </li>
     * <li> 如果集合为 empty 则不会进行 sql 拼接 </li>
     *
     * @param condition 执行条件
     * @param column    字段
     * @param coll      数据集合
     * @return children
     */
    <T> Children in(boolean condition, SFunction<T, ?> column, Collection<?> coll);

    /**
     * ignore
     *
     * @param column
     * @param values
     */
    default <T> Children in(SFunction<T, ?> column, Object... values) {
        return in(true, column, values);
    }

    /**
     * 字段 IN (v0, v1, ...)
     * <p>例: in("id", 1, 2, 3, 4, 5)</p>
     *
     * <li> 注意！数组为空若存在逻辑错误，请在 condition 条件中判断 </li>
     * <li> 如果动态数组为 empty 则不会进行 sql 拼接 </li>
     *
     * @param condition 执行条件
     * @param column    字段
     * @param values    数据数组
     * @return children
     */
    <T> Children in(boolean condition, SFunction<T, ?> column, Object... values);

    /**
     * ignore
     */
    default <T> Children inSql(SFunction<T, ?> column, String sql, Map<String, Object> paramMap) {
        return inSql(true, column, sql, paramMap);
    }

    /**
     * ignore
     */
    default <T> Children inSql(SFunction<T, ?> column, String sql) {
        return inSql(true, column, sql, null);
    }

    /**
     * 字段 IN (v0, v1, ...)
     * <p>例: in("id", 1, 2, 3, 4, 5)</p>
     *
     * <li> 注意！数组为空若存在逻辑错误，请在 condition 条件中判断 </li>
     * <li> 如果动态数组为 empty 则不会进行 sql 拼接 </li>
     *
     * @param condition 执行条件
     * @param sql    子查询sql
     * @param paramMap    子查询条件值
     * @return children
     */
    <T> Children inSql(boolean condition, SFunction<T, ?> column, String sql, Map<String, Object> paramMap);

    /**
     * ignore
     *
     * @param columns
     * @param values
     * @param <T>
     * @return
     */
    default <T> Children inb(Collection<SFunction<T, ?>> columns, Collection<Object[]> values) {
        return inb(true, columns, values);
    }

    /**
     * (字段1,字段2...) IN ((v0, v1...), (v2, v3...)...)
     * <p>例: in("id","code", Object[]...)</p>
     *
     * <li> 注意！数组为空若存在逻辑错误，请在 condition 条件中判断 </li>
     * <li> 如果动态数组为 empty 则不会进行 sql 拼接 </li>
     *
     * @param condition 执行条件
     * @param columns   字段集合
     * @param values    数据数组
     * @return children
     */
    <T> Children inb(boolean condition, Collection<SFunction<T, ?>> columns, Collection<Object[]> values);

    /**
     * ignore
     *
     * @param column
     * @param coll
     */
    default <T> Children notIn(SFunction<T, ?> column, Collection<?> coll) {
        return notIn(true, column, coll);
    }

    /**
     * 字段 NOT IN (value.get(0), value.get(1), ...)
     * <p>例: notIn("id", Arrays.asList(1, 2, 3, 4, 5))</p>
     *
     * @param condition 执行条件
     * @param column    字段
     * @param coll      数据集合
     * @return children
     */
    <T> Children notIn(boolean condition, SFunction<T, ?> column, Collection<?> coll);

    /**
     * ignore
     *
     * @param column
     * @param value
     */
    default <T> Children notIn(SFunction<T, ?> column, Object... value) {
        return notIn(true, column, value);
    }

    /**
     * 字段 NOT IN (v0, v1, ...)
     * <p>例: notIn("id", 1, 2, 3, 4, 5)</p>
     *
     * @param condition 执行条件
     * @param column    字段
     * @param values    数据数组
     * @return children
     */
    <T> Children notIn(boolean condition, SFunction<T, ?> column, Object... values);
}
